﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using FinPlusCompCore;
using QLNet;
using p = FinPlusCompQuant.QLConvParser;

namespace FinPlusCompQuant
{
    public class BondCurve : FinPlusComponent
    {
        public PiecewiseYieldCurve<Discount, LogLinear> PiecewiseBondCurve { get; private set; }
        public BondEngine BondEngine { get; private set; }

        //construct
        public BondCurve(Market market, string name, string discountCurveName, DateTime settlementDate, string[] rates, string dayCount, double tolerance, string holidays = "")
        {
            Id = name;
            var calendar = p.Calendar(holidays);
            var helpers = market.GetRateHelpers(rates);

            PiecewiseBondCurve = new PiecewiseYieldCurve<Discount, LogLinear>(calendar.adjust(settlementDate), helpers, p.DayCount(dayCount));
            market.SetCurve(name, PiecewiseBondCurve);
            BondEngine = new BondEngine(market, name, discountCurveName);
        }
    }
}
